/**********************************************************************
  The MIT License (MIT)
  Copyright (c) 2012 sunriseyuen

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files
  (the "Software"), to deal in the Software without restriction,
  including without limitation the rights to use, copy, modify, merge,
  publish, distribute, sublicense, and/or sell copies of the Software,
  and to permit persons to whom the Software is furnished to do so,
  subject to the following conditions:

  The above copyright notice and this permission notice shall be included
  in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
  THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ***********************************************************************/

#define _DEF_CCY_CODE
#define _ZZDEBUG
#define _PROJ_DC

#region Using directives

using System;
using System.Text;
using System.IO;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;

using Muki.Framework;
using Muki.Framework.UI;
using Muki.Framework.Business;
using Muki.Framework.Util;
using Muki.UserDefine;
using Muki.Entity;
using Dot.StreamObject;

#endregion

namespace Muki.UserPanel
{

	public class UID02135AUI:BaseAction
	{
		public UID02135AUI()
		{
		}

		public override void OnRetrieve(string cDefined_Code)
		{
			if (!_Retrieve(cDefined_Code))
			{
				if (cDefined_Code=="")
				{
					_UID02135AV.Exceptions.Clear();
					if (!_Retrieve("MN"))
					{
						if (!_Retrieve("MP")){
							this.OnDefault();
						}
					}
				}
			}
		}

		private bool _Retrieve(string cDefined_Code)
		{
			VContexts _VContexts=new VContexts();

			_VContexts.setValue("UDEF_CODE",cDefined_Code);

				UID02135AE _Entity=_UID02135AV.Entity;

				if (cDefined_Code=="PICKUP") {
					Spliter _PK_Spliter      = new Spliter(_UID02135AV.ZZEventOpts);
					_PK_Spliter.Separator    = '|';
					_PK_Spliter.Separatorb   = '=';
					_PK_Spliter.DecodeBase64 = true;
					_PK_Spliter.Split();

							_Entity.ITEM_NO=_PK_Spliter["ITEM_NO"];
				}else if (cDefined_Code=="ACTIVETAB") {
					_UID02135AV.ZZLookup               = _UID02135AV.STATUS_DATA["UID02135A","lookup"];

					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["t1"]=_UID02135AV.STATUS_DATA["UID02135A","t1"];
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["t2"]=_UID02135AV.STATUS_DATA["UID02135A","t2"];
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["t3"]=_UID02135AV.STATUS_DATA["UID02135A","t3"];

					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["v1"]=_UID02135AV.STATUS_DATA["UID02135A","v1"];
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["v2"]=_UID02135AV.STATUS_DATA["UID02135A","v2"];
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["v3"]=_UID02135AV.STATUS_DATA["UID02135A","v3"];
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["Restrict"]    =_UID02135AV.STATUS_DATA["UID02135A","Restrict"]    ;
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["AbsolutePage"]=_UID02135AV.STATUS_DATA["UID02135A","AbsolutePage"];
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["Condition"]   =_UID02135AV.STATUS_DATA["UID02135A","Condition"]   ;
					_UID02135AV.CellsPanel.VIEW_STATUS_DATA["ZZPageSize"]=_UID02135AV.STATUS_DATA["UID02135A","ZZPageSize"];

								_Entity.ITEM_NO=_UID02135AV.STATUS_DATA["UID02135A","PK_ITEM_NO"];
				}else{
					_VContexts.setValue("lookup",_UID02135AV.ZZLookup);

					_UID02135AV.STATUS_DATA["UID02135A","lookup"] = _UID02135AV.ZZLookup;
				}

				UID02135AE _NewEntity=_UID02135AM.Retrieves(_VContexts,_Entity);

				if (_NewEntity.DATA_STATUS_CODE=="Verified") {
					_UID02135AV.Entity             = _NewEntity;
					_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
					_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
				}
				_UID02135AV.Exceptions=_NewEntity.Exceptions;
				return _NewEntity.DATA_STATUS_CODE=="Verified";
		}

		public override void OnDefault()
		{
			UID02135AE _Entity=new UID02135AE();

			UID02135AE _NewEntity=_UID02135AM.Default(_Entity);

			if (_NewEntity.Exceptions.Count==0) {
				this.Trans.Commit();

				_UID02135AV.Entity             = _NewEntity;
				_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
				_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
			}
			_UID02135AV.Exceptions=_NewEntity.Exceptions;

		}

		public override void OnUpdate()
		{

			UID02135AE _NewEntity=_UID02135AM.Update(_UID02135AV.Entity);

			if (_NewEntity.Exceptions.Count==0){
				this.Trans.Commit();

				_UID02135AV.Entity             = _NewEntity;
				_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
				_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
			}
			_UID02135AV.Exceptions=_NewEntity.Exceptions;

		}		

		public override void OnAddNew()
		{

			UID02135AE _NewEntity=_UID02135AM.AddNew(_UID02135AV.Entity);

			foreach (LogisticException tmp in _NewEntity.Exceptions)
			{
				ZZTrace.Debug(ZFILE_NAME,tmp);
			}

			if (_NewEntity.Exceptions.Count==0) {
				this.Trans.Commit();

				_UID02135AV.Entity             = _NewEntity;
				_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
				_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
			}
			_UID02135AV.Exceptions=_NewEntity.Exceptions;

		}

		public override void OnChange(string cArg_Code)
		{

			if (cArg_Code!="") {
				_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
				_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
			}else{

				MessageInfo oMessageInfo  = new MessageInfo();
				oMessageInfo.DbName       = this.DbName;
				oMessageInfo.Trans        = this.Trans;
				oMessageInfo.ZZLOGON_LANG = this.ZZLOGON_LANG;
				oMessageInfo.ZZLOGON_SSD  = this.ZZLOGON_SSD;

				int _SUCCESS=0;
				int _FAILURE=0;
				if (_UID02135AV.ZZMODEL_DATA=="B") {

					_UID02135AV.ZZWxf.MoveFirst();
					while (!_UID02135AV.ZZWxf.EOF) {
						_UID02135AV.ZZWxf.Operation="P";
						_UID02135AV.ZZWxf.Reference="";

						VContexts _VContexts=new VContexts();

						_VContexts.setValue("UDEF_CODE","READ");

						bool Verified=false;
						UID02135AE _NewEntity=null;
						if (_UID02135AV.ZZWxf.PK_DATA!=""){

							Spliter _PK_Spliter      = new Spliter(_UID02135AV.ZZWxf.PK_DATA);
							_PK_Spliter.Separator    = '|';
							_PK_Spliter.Separatorb   = '=';
							_PK_Spliter.DecodeBase64 = true;
							_PK_Spliter.Split();

							UID02135AE _Entity=_UID02135AV.Entity;

									_Entity.ITEM_NO=_PK_Spliter["ITEM_NO"];

							_NewEntity=_UID02135AM.Retrieves(_VContexts,_Entity);

							if (_NewEntity.DATA_STATUS_CODE=="Verified") 
							{
								Verified=true;
								foreach (AttributeMapping _AttributeMapping in _UID02135AV.ZZWxf.Fields)
								{
									if (_AttributeMapping.STATUS_CODE.IndexOf("UPDATE")>=0) {
												if (_AttributeMapping.Name=="PARTBLM.PKG_ORD") {
														_NewEntity.PKG_ORD=_UID02135AV.ZZWxf.getDecimal(_AttributeMapping.Name);
												}
												if (_AttributeMapping.Name=="PARTBLM.LEAD_TM") {
														_NewEntity.LEAD_TM=_UID02135AV.ZZWxf.getInteger(_AttributeMapping.Name);
												}
									}
								}
							}else{
								_NewEntity=_Entity;
							}
						}
						if (Verified)
						{
							foreach (LogisticException tmp in _NewEntity.Exceptions)
							{
								ZZTrace.Debug(ZFILE_NAME,tmp);
							}

							UID02135AE _NewEntity2=_UID02135AM.Update(_NewEntity);

							string cMsg="";
							foreach (LogisticException tmp in _NewEntity2.Exceptions)
							{
								cMsg=cMsg+oMessageInfo.Message("UID02135A",tmp)+"||";
							}

							if (_NewEntity2.Exceptions.Count==0)
							{
								UID02135AE _NewEntity3=_UID02135AM.Retrieves(_VContexts,_NewEntity2);

								foreach (LogisticException tmp in _NewEntity3.Exceptions)
								{
									ZZTrace.Debug(ZFILE_NAME,tmp);
								}

								if (_NewEntity3.DATA_STATUS_CODE=="Verified")
								{
									_SUCCESS++;
									_UID02135AV.ZZWxf.Operation="Y";
								}else{
									_UID02135AV.ZZWxf.Operation="R";
									_FAILURE++;
								}

								foreach (AttributeMapping _AttributeMapping in _UID02135AV.ZZWxf.Fields)
								{
												if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME01") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME01"]=_NewEntity3.ITEM_NAME01;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME02") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME02"]=_NewEntity3.ITEM_NAME02;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME05") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME05"]=_NewEntity3.ITEM_NAME05;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_ABBR_NAME") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_ABBR_NAME"]=_NewEntity3.ITEM_ABBR_NAME;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_ALIAS_NAME") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_ALIAS_NAME"]=_NewEntity3.ITEM_ALIAS_NAME;
												}
												if (_AttributeMapping.Name=="PARTBLM.UOM_CODE") {
													_UID02135AV.ZZWxf["PARTBLM.UOM_CODE"]=_NewEntity3.UOM_CODE;
												}
												if (_AttributeMapping.Name=="PARTBLM.MBC_CODE") {
													_UID02135AV.ZZWxf["PARTBLM.MBC_CODE"]=_NewEntity3.MBC_CODE;
												}
												if (_AttributeMapping.Name=="PARTBLM.PKG_ORD") {
													_UID02135AV.ZZWxf["PARTBLM.PKG_ORD"]=_NewEntity3.PKG_ORD;
												}
												if (_AttributeMapping.Name=="PARTBLM.LEAD_TM") {
													_UID02135AV.ZZWxf["PARTBLM.LEAD_TM"]=_NewEntity3.LEAD_TM;
												}
								}
							}else{
								_FAILURE++;
								_UID02135AV.ZZWxf.Reference=cMsg;
								_UID02135AV.ZZWxf.Operation="F";

								foreach (AttributeMapping _AttributeMapping in _UID02135AV.ZZWxf.Fields)
								{
												if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME01") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME01"]=_NewEntity2.ITEM_NAME01;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME02") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME02"]=_NewEntity2.ITEM_NAME02;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME05") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME05"]=_NewEntity2.ITEM_NAME05;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_ABBR_NAME") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_ABBR_NAME"]=_NewEntity2.ITEM_ABBR_NAME;
												}
												if (_AttributeMapping.Name=="PARTBLM.ITEM_ALIAS_NAME") {
													_UID02135AV.ZZWxf["PARTBLM.ITEM_ALIAS_NAME"]=_NewEntity2.ITEM_ALIAS_NAME;
												}
												if (_AttributeMapping.Name=="PARTBLM.UOM_CODE") {
													_UID02135AV.ZZWxf["PARTBLM.UOM_CODE"]=_NewEntity2.UOM_CODE;
												}
												if (_AttributeMapping.Name=="PARTBLM.MBC_CODE") {
													_UID02135AV.ZZWxf["PARTBLM.MBC_CODE"]=_NewEntity2.MBC_CODE;
												}
												if (_AttributeMapping.Name=="PARTBLM.PKG_ORD") {
													_UID02135AV.ZZWxf["PARTBLM.PKG_ORD"]=_NewEntity2.PKG_ORD;
												}
												if (_AttributeMapping.Name=="PARTBLM.LEAD_TM") {
													_UID02135AV.ZZWxf["PARTBLM.LEAD_TM"]=_NewEntity2.LEAD_TM;
												}
								}
							}
							//}
					}else{
						if (_NewEntity==null)
						{
							_NewEntity=new UID02135AE();
						}

						foreach (AttributeMapping _AttributeMapping in _UID02135AV.ZZWxf.Fields)
						{
							if (_AttributeMapping.STATUS_CODE.IndexOf("UPDATE")>=0 || _AttributeMapping.STATUS_CODE.IndexOf("ADDNEW")>=0)
							{
										if (_AttributeMapping.Name=="PARTBLM.ITEM_NO") {
												_NewEntity.ITEM_NO=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME01") {
												_NewEntity.ITEM_NAME01=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME02") {
												_NewEntity.ITEM_NAME02=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME05") {
												_NewEntity.ITEM_NAME05=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.ITEM_ABBR_NAME") {
												_NewEntity.ITEM_ABBR_NAME=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.ITEM_ALIAS_NAME") {
												_NewEntity.ITEM_ALIAS_NAME=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.UOM_CODE") {
												_NewEntity.UOM_CODE=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.MBC_CODE") {
												_NewEntity.MBC_CODE=_UID02135AV.ZZWxf.getValue(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.PKG_ORD") {
												_NewEntity.PKG_ORD=_UID02135AV.ZZWxf.getDecimal(_AttributeMapping.Name);
										}
										if (_AttributeMapping.Name=="PARTBLM.LEAD_TM") {
												_NewEntity.LEAD_TM=_UID02135AV.ZZWxf.getInteger(_AttributeMapping.Name);
										}
							}
						}

						UID02135AE _NewEntity7=_UID02135AM.AddNew(_NewEntity);

						string cMsg="";
						foreach (LogisticException tmp in _NewEntity7.Exceptions)
						{
							cMsg=cMsg+oMessageInfo.Message("UID02135A",tmp)+"||";
						}

						if (_NewEntity7.Exceptions.Count==0) {
							UID02135AE _NewEntity8=_UID02135AM.Retrieves(_VContexts,_NewEntity7);
							cMsg="";
							foreach (LogisticException tmp in _NewEntity8.Exceptions)
							{
								cMsg=cMsg+oMessageInfo.Message("UID02135A",tmp)+"||";
								ZZTrace.Debug(ZFILE_NAME,tmp);
							}

							if (_NewEntity8.DATA_STATUS_CODE=="Verified") {
								_SUCCESS++;
								_UID02135AV.ZZWxf.PK_DATA=_NewEntity8.PK_DATA;
								_UID02135AV.ZZWxf.Operation="Y";
							}else{
								_UID02135AV.ZZWxf.Reference=cMsg;
								_UID02135AV.ZZWxf.Operation="R";
								_FAILURE++;
							}

							foreach (AttributeMapping _AttributeMapping in _UID02135AV.ZZWxf.Fields)
							{

											if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME01") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME01"]=_NewEntity8.ITEM_NAME01;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME02") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME02"]=_NewEntity8.ITEM_NAME02;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME05") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME05"]=_NewEntity8.ITEM_NAME05;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_ABBR_NAME") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_ABBR_NAME"]=_NewEntity8.ITEM_ABBR_NAME;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_ALIAS_NAME") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_ALIAS_NAME"]=_NewEntity8.ITEM_ALIAS_NAME;
											}

											if (_AttributeMapping.Name=="PARTBLM.UOM_CODE") {
												_UID02135AV.ZZWxf["PARTBLM.UOM_CODE"]=_NewEntity8.UOM_CODE;
											}

											if (_AttributeMapping.Name=="PARTBLM.MBC_CODE") {
												_UID02135AV.ZZWxf["PARTBLM.MBC_CODE"]=_NewEntity8.MBC_CODE;
											}

											if (_AttributeMapping.Name=="PARTBLM.PKG_ORD") {
												_UID02135AV.ZZWxf["PARTBLM.PKG_ORD"]=_NewEntity8.PKG_ORD;
											}

											if (_AttributeMapping.Name=="PARTBLM.LEAD_TM") {
												_UID02135AV.ZZWxf["PARTBLM.LEAD_TM"]=_NewEntity8.LEAD_TM;
											}

							}

						}else{
							_FAILURE++;
							foreach (AttributeMapping _AttributeMapping in _UID02135AV.ZZWxf.Fields)
							{

											if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME01") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME01"]=_NewEntity7.ITEM_NAME01;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME02") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME02"]=_NewEntity7.ITEM_NAME02;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_NAME05") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_NAME05"]=_NewEntity7.ITEM_NAME05;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_ABBR_NAME") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_ABBR_NAME"]=_NewEntity7.ITEM_ABBR_NAME;
											}

											if (_AttributeMapping.Name=="PARTBLM.ITEM_ALIAS_NAME") {
												_UID02135AV.ZZWxf["PARTBLM.ITEM_ALIAS_NAME"]=_NewEntity7.ITEM_ALIAS_NAME;
											}

											if (_AttributeMapping.Name=="PARTBLM.UOM_CODE") {
												_UID02135AV.ZZWxf["PARTBLM.UOM_CODE"]=_NewEntity7.UOM_CODE;
											}

											if (_AttributeMapping.Name=="PARTBLM.MBC_CODE") {
												_UID02135AV.ZZWxf["PARTBLM.MBC_CODE"]=_NewEntity7.MBC_CODE;
											}

											if (_AttributeMapping.Name=="PARTBLM.PKG_ORD") {
												_UID02135AV.ZZWxf["PARTBLM.PKG_ORD"]=_NewEntity7.PKG_ORD;
											}

											if (_AttributeMapping.Name=="PARTBLM.LEAD_TM") {
												_UID02135AV.ZZWxf["PARTBLM.LEAD_TM"]=_NewEntity7.LEAD_TM;
											}

							}
							_UID02135AV.ZZWxf.Reference=cMsg;
							_UID02135AV.ZZWxf.Operation="F";
						}

					}

					_UID02135AV.ZZWxf.MoveNext();
				}

				_UID02135AV.ZZWxf.Variable("SUCCESS",_SUCCESS);
				_UID02135AV.ZZWxf.Variable("FAILURE",_FAILURE);

				if (_FAILURE==0 && _SUCCESS>0) {
					this.Trans.Commit();
				}

			}
		}
	}

	public override void OnDelete()
	{
		int _SUCCESS=0;
		int _FAILURE=0;

		UID02135AE _NewEntity=new UID02135AE();

		if (_UID02135AV.lnk_MODE=="B") {
			_UID02135AV.ZZWxf.MoveFirst();
			while (!_UID02135AV.ZZWxf.EOF)
			{
				VContexts _VContexts=new VContexts();

				_VContexts.setValue("UDEF_CODE","");

				if (_UID02135AV.ZZWxf.PK_DATA!="" && _UID02135AV.ZZWxf.Operation=="f"  ) {

					Spliter _PK_Spliter      = new Spliter(_UID02135AV.ZZWxf.PK_DATA);
					_PK_Spliter.Separator    = '|';
					_PK_Spliter.Separatorb   = '=';
					_PK_Spliter.DecodeBase64 = true;
					_PK_Spliter.Split();

					UID02135AE _Entity=_UID02135AV.Entity;

							_Entity.ITEM_NO=_PK_Spliter["ITEM_NO"];

					_NewEntity=_UID02135AM.Delete(_UID02135AV.Entity);

					if (_NewEntity.Exceptions.Count==0) {
						_SUCCESS++;
					}else{
						_FAILURE++;
					}
				}
				_UID02135AV.ZZWxf.MoveNext();
			}

			if (_SUCCESS>0 && _FAILURE==0 ) {
				//this.Empty();
				this.OnRetrieve("");

				this.Trans.Commit();

			}

			if (_SUCCESS>=0 && _FAILURE==0 ) {
				_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
				_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
			}

		}else{
			_NewEntity=_UID02135AM.Delete(_UID02135AV.Entity);

			if (_NewEntity.Exceptions.Count==0) {

				this.OnRetrieve("");

				this.Trans.Commit();

				_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
				_UID02135AV.ZZVIEW_MODE_CODE = _UID02135AV.ZZEventMode;
			}
		}

		_UID02135AV.Exceptions=_NewEntity.Exceptions;

	}

	public override void OnUserDef(string cAction_Code,string cDefined_Code)
	{
		VContexts _VContexts=new VContexts();

		_VContexts.setValue("UDEF_CODE",cDefined_Code);
		_VContexts.setValue("Events",cAction_Code);
		_VContexts.setValue("STATUS_CODE",_UID02135AV.ZZVIEW_STATUS_CODE);
		_VContexts.setValue("Sender", "UID02135A");

		UID02135AE _NewEntity=_UID02135AM.UserDefine(_VContexts,_UID02135AV.Entity);

		if (_NewEntity.Exceptions.Count==0) {
			_UID02135AV.Entity             = _NewEntity;
			_UID02135AV.ZZVIEW_STATUS_CODE = _UID02135AV.ZZEventStatus;
			_UID02135AV.ZZVIEW_MODE_CODE   = _UID02135AV.ZZEventMode;

		}
		_UID02135AV.Exceptions=_NewEntity.Exceptions;
	}

	public override void Process()
	{
		try
		{
			checked
			{
				ZZTrace.Debug(ZFILE_NAME,"ZZEventStatus="+_UID02135AV.ZZEventStatus);
				ZZTrace.Debug(ZFILE_NAME,"ZZEventMode="+_UID02135AV.ZZEventMode);

				this.Trans                = new StreamContext(this.DbName);
				this.Trans.Writeable      = true;
				_UID02135AM.Trans       = this.Trans;
				_UID02135AM.ZZLOGON_SSD = _UID02135AV.ZZLOGON_SSD;
				_UID02135AM.Initialize();

				base.Process();

				ZZTrace.Error(ZFILE_NAME,"PK_XX");

			}
		}
		catch (LogisticException ErrMsg)
		{
			_UID02135AV.Exceptions.Add(ErrMsg);

			string cMessage = "Message=[" + ErrMsg.Message + "]" + "\nSource=[" + ErrMsg.Source + "]\nStackTrace=[" + ErrMsg.StackTrace + "]\nTargetSite=[" + ErrMsg.TargetSite + "]";

			ZZTrace.Error(ZFILE_NAME,cMessage);

			ZZTrace.Error(ZFILE_NAME,ErrMsg);

			try
			{
				this.Trans.RollBack();
			}
			catch (Exception Ex)
			{
				cMessage = "Message=[" + ErrMsg.Message + "]" + "\nSource=[" + ErrMsg.Source + "]\nStackTrace=[" + ErrMsg.StackTrace + "]\nTargetSite=[" + ErrMsg.TargetSite + "]";

				ZZTrace.Error(ZFILE_NAME,cMessage);

				ZZTrace.Error(ZFILE_NAME,Ex);
			}

		}
		catch (Exception e)
		{
			string cMessage2 = "Message=[" + e.Message + "]" + "\nSource=[" + e.Source + "]\nStackTrace=[" + e.StackTrace + "]\nTargetSite=[" + e.TargetSite + "]";

			ZZTrace.Error(ZFILE_NAME,cMessage2);

			_UID02135AV.Exceptions.Add(new LogisticException("UID02135A","SystemError",""));
			ZZTrace.Error(ZFILE_NAME,e);
			try
			{
				this.Trans.RollBack();
			}
			catch (Exception)
			{
			}
		}
		finally
		{
			this.Trans.Close();
		}
	}

	public override void Process_Aft()
	{
		if (_UID02135AV.ZZVIEW_MODE_CODE=="B" || _UID02135AV.ZZVIEW_MODE_CODE=="N"){
			_UID02135AM.DbName      = this.DbName;
			_UID02135AM.Trans       = this.ReadMode;
			_UID02135AM.ZZLOGON_SSD = _UID02135AV.ZZLOGON_SSD;

			VContexts _VContexts=new VContexts();

			_VContexts=_UID02135AV.CellsPanel.VIEW_STATUS_DATA;
			_VContexts.setValue("lookup",_UID02135AV.STATUS_DATA["UID02135A","lookup"]);

			UID02135AE _Entity=_UID02135AV.Entity;

			_UID02135AM.Search(_VContexts, _Entity);
			_UID02135AV.CellsPanel.VIEW_STATUS_DATA=_VContexts;

			_UID02135AV.STATUS_DATA["UID02135A","t1"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["t1"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","t2"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["t2"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","t3"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["t3"].ToString();

			_UID02135AV.STATUS_DATA["UID02135A","v1"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["v1"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","v2"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["v2"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","v3"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["v3"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","Restrict"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["Restrict"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","AbsolutePage"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["AbsolutePage"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","Condition"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["Condition"].ToString();
			_UID02135AV.STATUS_DATA["UID02135A","ZZPageSize"]=_UID02135AV.CellsPanel.VIEW_STATUS_DATA["ZZPageSize"].ToString();

		}
	}

	public override void OnInit(HttpContext  objHttpContext)		
	{

		_UID02135AM = new UID02135AM();
		_UID02135AV = new UID02135AV();

		_UID02135AV.OnInit(objHttpContext);

		this.DbName                = _UID02135AV.DbName;
		this.ZZEventArgs           = _UID02135AV.ZZEventArgs;
		this.ZZVIEW_STATUS_CODE    = _UID02135AV.ZZVIEW_STATUS_CODE;
		this.ZZVIEW_MODE_CODE      = _UID02135AV.ZZVIEW_MODE_CODE;
		this.ZZLOGON_LANG = _UID02135AV.ZZLOGON_LANG;
		this.ReadMode=_UID02135AV.Trans;

		_UID02135AM.ZZLOGON_ID   = _UID02135AV.ZZLOGON_ID;
		_UID02135AM.ZZLOGON_LANG = _UID02135AV.ZZLOGON_LANG;
		_UID02135AV.APP_PATH     = this.APP_PATH;
		_UID02135AV.setValue();
	}

	public override void Render(HtmlTextWriter objTextWriter)
	{
		try
		{
			if (_UID02135AV.ZZMODEL_DATA=="B")
			{
				_UID02135AV.ZZWxf.Variable("lnk_RW_NO",_UID02135AV.lnk_RW_NO);

				objTextWriter.WriteLine(_UID02135AV.ZZWxf.ToString());
			}else{
				_UID02135AV.getValue();
				_UID02135AV.Render(objTextWriter);
			}
		}
		finally
		{
			this.ReadMode.Close();
		}
	}

	const  string ZFILE_NAME   ="UID02135AC";
	const  string MUKI_EDITION ="MIN";

	private UID02135AM      _UID02135AM;
	private UID02135AV      _UID02135AV;

#region screen element
#endregion
}
}
